<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('avatar')->nullable();
            $table->string('mobile')->unique();//电话
            $table->tinyInteger('sex')->default(1);
            $table->string('idcard')->default('/');
            $table->unsignedBigInteger('role_id')->nullable()->index();
            $table->unsignedBigInteger('company_id')->index();
            $table->string('password');
            $table->string('openid')->nullable();
            $table->string('ip')->nullable();
            $table->string('posts')->nullable()->default('/');
            $table->tinyInteger('formal')->default(1);
            $table->tinyInteger('status')->default(1);
            $table->tinyInteger('employees')->default(1)->comment('1在职 2离职');
            $table->decimal('basic_salary',10,2)->default(0)->comment('基本工资');
            $table->timestamps();
        });


        Schema::create('user_mores', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('user_id')->index();
            $table->string('nationality')->nullable()->comment('民族')->default('/');
            $table->string('address')->nullable()->comment('地址')->default('/');
            $table->string('health')->nullable()->comment('健康状况')->default('/');
            $table->string('marital')->nullable()->comment('婚姻状况')->default('/');
            $table->string('email')->nullable()->comment('')->default('/');
            $table->string('qq')->nullable()->comment('')->default('/');
            $table->string('idcard_file')->nullable()->comment('');
            $table->string('height')->nullable()->comment('身高')->default('/');
            $table->string('education_level')->nullable()->comment('最高学历')->default('/');
            $table->string('graduation_cert')->nullable()->comment('毕业证');
            $table->string('medical_history')->nullable()->comment('有无隐藏病史')->default('/');
            $table->string('political')->nullable()->comment('政治面貌')->default('/');
            $table->date('entry_date')->nullable()->comment('入职时间');
            $table->string('trial_period')->nullable()->comment('试用期')->default('/');
            $table->string('handbook_commitment_letter')->nullable()->comment('员工手册承诺书');
            $table->string('emergency_contact')->nullable()->comment('紧急联系人')->default('/');
            $table->string('emergency_contact_mobile')->nullable()->comment('紧急联系及人电话')->default('/');
            
            $table->decimal('probationary_salary',10,2)->default(0)->comment('试用期工资');
            $table->decimal('basic_year_salary',10,2)->default(0)->comment('基本年薪资');
            $table->string('salary_agreements')->nullable()->comment('薪资补充协议')->default('');
            $table->decimal('subsidies',10,2)->default(0)->comment('岗位补贴');
            $table->decimal('other_subsidies',10,2)->default(0)->comment('其他补贴');
            $table->decimal('rewards',10,2)->default(0)->comment('研发奖励');
            $table->decimal('total_salary',10,2)->default(0)->comment('累计工资');
            

            $table->string('previous_unit')->nullable()->comment('上家单位名称')->default('/');
            $table->string('previous_unit_user')->nullable()->comment('证明人及电话')->default('/');
            $table->string('previous_unit_mobile')->nullable()->comment('证明人及电话')->default('/');
            $table->string('resignation_cert')->nullable()->comment('离职证明');
            $table->string('social_security_cert')->nullable()->comment('社保证明');
            $table->string('bank_statement')->nullable()->comment('银行流水');
            $table->string('employment_form')->nullable()->comment('入职登记表');
            $table->string('labor_contract')->nullable()->comment('劳动合同');
            $table->string('company_policy_agreement')->nullable()->comment('员工手册、保密、培训协议');
            $table->string('probation_approval_form')->nullable()->comment('转正申请表');
            $table->string('employment_registration')->nullable()->comment('调岗、调薪申请');

            $table->string('resignation_report')->nullable()->comment('离职报告');
            $table->string('out_report')->nullable()->comment('辞职报告');
            $table->string('reason_leaving')->nullable()->comment('离职原因')->default('/');
            $table->date('resign_date')->nullable()->comment('离职时间');
            $table->string('handover_records')->nullable()->comment('交接记录');
            $table->string('resignation_interview')->nullable()->comment('约谈内容');
            $table->string('resignation_interview_file')->nullable()->comment('约谈记要');
            $table->string('salary_settlement_cert')->nullable()->comment('薪资结清证明');

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
        Schema::dropIfExists('user_mores');
    }
};
